import del from "rollup-plugin-delete";
import copy from "rollup-plugin-copy";
import typescript2 from "rollup-plugin-typescript2";
import terser from "@rollup/plugin-terser";

const tsconfigOverride = {
  include: ["packages/utils/**/*.ts"],
  compilerOptions: {
    declaration: true,
    declarationDir: "dist/utils/types",
    declarationMap: true,
  },
};

export default {
  input: "packages/utils/src/index.ts",
  output: {
    dir: "dist/utils",
    format: "es",
  },
  external: ["vue"],
  plugins: [
    del({ targets: "dist/utils" }),
    typescript2({
      tsconfig: "tsconfig.app.json",
      tsconfigOverride: tsconfigOverride,
      useTsconfigDeclarationDir: true,
      include: ["packages/utils/**/*.ts"],
    }),
    terser(),
    copy({
      targets: [
        {
          src: "packages/utils/package.json",
          dest: "dist/utils",
        },
      ],
    }),
  ],
} as import("rollup").RollupOptions;
